import pytest
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from common.utils import Utils
from po.loginPage import login_page

@pytest.fixture(scope='function')
def driver():
    #读取配置
    config_dict = Utils.load_yaml(r'config/config.yaml')
    driver = webdriver.Chrome(service=Service(config_dict['env']['chrome']))
    print(config_dict['env']['chrome'])
    driver.maximize_window()

    yield driver

    driver.quit()


@pytest.fixture(scope='module')
def driver_login():
    
    config_dict = Utils.load_yaml(r'config/config.yaml')
    driver = webdriver.Chrome(service=Service(config_dict['env']['chrome']))
    print(config_dict['env']['chrome'])
    driver.maximize_window()
    driver.get('http://127.0.0.1:8234')
    l_obj = login_page(driver)
    l_obj.login('byhy','sdfsdf')

    yield driver

    driver.quit()